package paystation.domain;

import java.rmi.RemoteException;

/**
 * The business logic of a Parking Pay Station.
 * 
 * Responsibilities:
 * 
 * 1) Accept payment; 2) Calculate parking time based on payment; 3) Know earning, parking time bought; 4) Issue receipts; 5) Handle buy and
 * cancel events.
 */
public interface PayStation extends StatusObservable{

    /**
     * Insert coin into the pay station and adjust state accordingly.
     * 
     * @param coinValue
     *            is an integer value representing the coin in cent. That is, a quarter is coinValue=25, etc.
     * @throws IllegalCoinException
     *             in case coinValue is not a valid coin value
     */
    public void addPayment(int coinValue) throws IllegalCoinException, RemoteException;

    /**
     * Read the machine's display. The display shows a numerical description of the amount of parking time accumulated so far based on
     * inserted payment.
     * 
     * @return the number to display on the pay station display
     */
    public int readDisplay() throws RemoteException;

    /**
     * Buy parking time. Terminate the ongoing transaction and return a parking receipt. A non-null object is always returned.
     * 
     * @return a valid parking receipt object.
     */
    public Receipt buy() throws RemoteException;

    /**
     * Cancel the present transaction. Resets the machine for a new transaction.
     */
    public void cancel() throws RemoteException;
}
